<template>
  <div id="talent">
    <van-list
      v-model="loading"
      :finished="finished"
      finished-text="没有更多了"
      @load="onLoad"
      :immediate-check="false"
    >
      <van-pull-refresh v-model="refreshing" @refresh="onRefresh">
        <p class="num">共{{talentList.length}}条结果</p>
        <!-- 达人 -->
        <div class="box" v-for="(item, i) in talentList" :key="i + 't'">
          <van-image round :src="item.logo" />
          <div class="right">
            <div class="wid">
              <p class="name">{{ item.nickName }}</p>
              <span class="type">{{ item.category }}</span>
            </div>
            <div class="total">
              <div>
                <span>{{ format_num(item.totalFans) }}</span>
                <span>粉丝总数</span>
              </div>
              <div>
                <span>{{ format_num(item.totalFavorite) }}</span>
                <span>点赞数</span>
              </div>

              <div>
                <span>{{ format_num(item.totalVideo) }}</span>
                <span>作品数</span>
              </div>
            </div>
          </div>
        </div>
      </van-pull-refresh>
    </van-list>
  </div>
</template>

<script>
import Vue from "vue";
import { Toast } from "vant";
Vue.use(Toast);
export default {
  name: "",
  components: {},
  data() {
    return {
      page: 1,
      pageSize: 20,
      talentList: [],
      //触底
      loading: false,
      finished: false,
      refreshing: false,
    };
  },
  computed: {},
  watch: {},
  created() {},
  mounted() {
    this.GetTalentList();
  },

  methods: {
    //接口数据
    GetTalentList() {
      if (this.talentList.length == 0) {
        Toast.loading({
          message: "加载中...",
          forbidClick: true,
          duration: 0,
        });
      }
      this.loading = true;
      this.$axios
        .get("/api/collection/GetAuthorsCollection", {
          params: {
            pageIndex: this.page,
            pageSize: this.pageSize,
          },
        })
        .then((res) => {
          if (res.data.code == 0) {
            Toast.clear();
            this.talentList = this.talentList.concat(res.data.data);
            this.loading = false;
            this.refreshing = false;
          }
        })
        .catch((err) => {
          console.log(err);
        });
    },

    //触底
     onLoad() {
       this.loading = true;
       if (this.page * this.pageSize > this.talentList.length) {
        this.loading = false;
        //this.finished = true;
      } else if (this.talentList.length > 0) {
         this.page = this.page + 1;
         this.GetTalentList();
       }
    },
    //上拉刷新
    onRefresh() {
      // 清空列表数据
      // this.finished = true;
      this.pageIndex = 1;
      // this.talentList = [];
      this.GetTalentList();
    },
},
};
</script>

<style lang='less' scoped>
//@import url();
#talent {
  margin-top: 0.2rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
}
.num{
      width: 100%;
      font-size: .373333rem;
      line-height:.373333rem;
      padding: .37333rem 0 .266rem .1rem;
}
.box {
  width: 9.2rem;
  margin: 0 auto;
  height: 2.266667rem;
  background-color: #ffffff;
  border-radius: 0.133333rem;
  display: flex;
  margin-bottom: 0.2rem;
}
.right {
  padding-left: 0.4rem;
}
.wid {
  display: flex;
  height: 0.666667rem;
  line-height: 0.666667rem;
  position: relative;
  top: 0.373333rem;
}
.name {
  max-width: 4.933333rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  height: 0.666667rem;
  font-size: 0.4rem;
  letter-spacing: 0.013333rem;
  color: #222222;
}
.type {
  padding: 0 0.133333rem;
  height: 0.473333rem;
  line-height: 0.453333rem;
  background-color: #f4f9ff;
  border-radius: 0.226667rem;
  border: solid 1px #1779ff;
  position: relative;
  top: 0.08rem;
  margin-left: 0.133333rem;
  font-size: 0.306667rem;
  color: #1779ff;
}
.total {
  display: flex;
  font-family: Dinpro-medium;
  font-size: 0.373333rem;
  margin-top: 0.4rem;
}
.total div {
  width: 1.36rem;
  padding-right: 1.093333rem;
}
.total div span:nth-child(1) {
  display: block;
  font-family: Dinpro-medium;
}
.total div span:nth-child(2) {
  font-size: 0.293333rem;
  font-weight: normal;
  font-stretch: normal;
  line-height: 0.4rem;
  letter-spacing: 0px;
  color: #888888;
}
//解决下拉刷新与标题切换问题
.van-pull-refresh { 
 	overflow: auto !important;
} 
/*定义滚动条高宽及背景
 高宽分别对应横竖滚动条的尺寸*/
::-webkit-scrollbar
{
    width:0;
    height:0;
}
</style>